package com.briup.jdk8.day01;

/**
 * 行为参数化
 */
public class Test2 {
    // 计算和
    public static int add(int a, int b){
        return a+b;
    }
    public static int multiply(int a, int b){
        return a*b;
    }
    public static int calculate(int a, int b , Action action){
        return action.calculate(a,b);
    }
    // 计算积
    public static void main(String[] args) {
        // 计算
        Action action = (a,b) -> a+b;
        calculate(1, 2, (a, b) -> a+b);
        calculate(4, 5, (a, b) -> a*b);
        // lambda表达式
        System.out.println(action);
    }
}
interface Action{
    int calculate(int a, int b);
}

